Sort profile refresh tokens by 'last used at' date (#4484)#7199
Merged
zsarnett merged 1 commit intohome-assistant:devfrom Oct 11, 2020
aav7fl:dev
Merged
Sort profile refresh tokens by 'last used at' date (#4484)#7199zsarnett merged 1 commit intohome-assistant:devfrom aav7fl:dev
zsarnett merged 1 commit intohome-assistant:devfrom
aav7fl:dev
Conversation
Contributor
|
Take a look at #7195. |
Contributor
Author
Thanks! Great catch 🙂 |
bramkragten
reviewed
Oct 2, 2020
Contributor
Author
|
@bramkragten
|
bramkragten
reviewed
Oct 2, 2020
bramkragten
reviewed
Oct 2, 2020
bramkragten
reviewed
Oct 2, 2020
9 tasks
bramkragten
reviewed
Oct 2, 2020
| ${this.hass.localize("ui.panel.profile.refresh_tokens.description")} | ||
| ${refreshTokens?.length | ||
| ? refreshTokens!.map( | ||
| ? refreshTokens!.sort(compareTokenLastUsedAt).map( |
Member
There was a problem hiding this comment.
We should do the sorting in the memoizeOne, to prevent doing it on every render, and only do it when the tokens are changed
Contributor
Author
There was a problem hiding this comment.
That makes sense. So change:
refreshTokens?.filter((token) => token.type === "normal").reverse()to
refreshTokens?.filter((token) => token.type === "normal").sort(compareTokenLastUsedAt)?
Contributor
There was a problem hiding this comment.
private _sortedTokens = memoizeOne((tokens) => tokens.sort(compareTokenLastUsedAt).map())Something like this. Break it into a private function
Member
There was a problem hiding this comment.
there is a memoize function already :-)
Contributor
Author
There was a problem hiding this comment.
@bramkragten Change pushed. Thanks for walking through with me on this.
bramkragten
approved these changes
Oct 2, 2020
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
The user profile page lists are tokens created by/used by said user. It's a bit of a mess when trying to find tokens that were recently used (and clearing out older tokens). This change sorts in ascending order the tokens by their
last used atdate.Previously there was no sorting mechanism (although it was sorted by chance with
created datedit appears).Type of change
Example configuration
No configuration change needed.
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed:
Documentation added/updated for www.home-assistant.ioNo configuration change needed.